package cn.ljlao.srpingevent.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: LiuZhen
 * @Created: 2021/12/7 21:59
 * @Description:
 */
@RestController
@Slf4j
public class Controller {

    @Autowired
    private ApplicationContext applicationContext;

    @RequestMapping("/test")
    public String test(){

        applicationContext.publishEvent(new MyEvent("测试"));
        //System.out.println("结束");
        log.info("结束");
        return "haha";
    }
}
